﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="Visit_List" CodeFile="Visit_List.aspx.cs" MasterPageFile="~/MasterPage.master" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
    <title>拜访历史</title>
    <script language="javascript" type="text/javascript">
        function expandcollapse(obj,row)
        {
            var div = document.getElementById(obj);
            var img = document.getElementById('img' + obj);
            
            if (div.style.display == "none")
            {
                div.style.display = "block";
                if (row == 'alt')
                {
                    img.src = "pfeil_auf.jpg";
                }
                else
                {
                    img.src = "pfeil_auf.jpg";
                }
                //img.alt = "Close to view other Customers";
                img.alt = "关闭查看客户信息";
            }
            else
            {
                div.style.display = "none";
                if (row == 'alt')
                {
                    img.src = "pfeil_zu.jpg";
                }
                else
                {
                    img.src = "pfeil_zu.jpg";
                }
                img.alt = "Expand to show Orders";
            }
        } 
            function setRadio(nowRadio)
            {
                var myForm,objRadio;
                myForm=document.forms[0];
                //alert(myForm);
                for(var i=0;i<myForm.length;i++)
                {
                    if(myForm.elements[i].type=="radio")
                    {
                        objRadio=myForm.elements[i];
                        ///alert(objRadio.name);
                        if(objRadio!=nowRadio && objRadio.name.indexOf("gvChannelType")>-1 && objRadio.name.indexOf("RadioButton1")>-1)
                        {
                        //alert(objRadio.name);
                            if(objRadio.checked)
                            {
                                objRadio.checked=false;
                            }
                        }
                    }
                }
            }

    </script>

</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
                    <table id="wsd_inputtable">
                        <tr>
                            <td class="tabletitle" colspan="6">
                                查询客户
                            </td>
                        </tr>
                        <tr>
                            <td class="tablefield">
                                客户类别:
                            </td>
                            <td nowrap="nowrap">
                                <asp:DropDownList runat="server" ID="ddlClass" Width="130">
                                </asp:DropDownList>
                            </td>
                            <td class="tablefield">
                                区域层次:
                            </td>
                            <td nowrap="nowrap">
                                <asp:DropDownList runat="server" ID="ddlLevel" meta:resourcekey="ddlLevelResource1"
                                    Width="130">
                                </asp:DropDownList>
                            </td>
                            <td class="tablefield">
                                销售渠道:
                            </td>
                            <td nowrap="nowrap">
                                <asp:DropDownList runat="server" ID="ddlChannel" Width="130">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td class="tablefield">
                                经销商:
                            </td>
                            <td nowrap="nowrap">
                                <asp:DropDownList runat="server" ID="ddlChain" Width="130">
                                </asp:DropDownList>
                            </td>
                            <td class="tablefield">
                                客户代码:
                            </td>
                            <td nowrap="nowrap">
                                <asp:TextBox runat="server" ID="txtCode"></asp:TextBox>
                            </td>
                            <td class="tablefield">
                                门店名称:
                            </td>
                            <td nowrap="nowrap">
                                <asp:TextBox runat="server" ID="txtName"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" class="buttonarea">
                                <asp:Button ID="btnQuery" runat="server" class="wsd_button2" Text="查询客户" OnClick="btnQueryCustomer_Click" />
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table id="wsd_inputtable">
                        <tr>
                            <td width="100%" class="tabletitle" >
                                客户列表
                            </td>
                        </tr>
                    </table>
                    <table id="wsd_listtable" width="100%">
                        <tr>
                            <td style="width: 100%">
                                <asp:GridView BorderWidth="0" Width="100%" ID="gvChannelType" runat="server" AutoGenerateColumns="false" EmptyDataText="没有可显示的数据." 
                                EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"   
                                    EnableEmptyContentRender="true" DataKeyNames="ID" OnRowDataBound="gvChannelType_RowDataBound">
                                    <HeaderStyle CssClass="titlist" />
                                    <Columns>
                                        <asp:BoundField HeaderText="客户ID" DataField="ID" Visible="false" />
                                        <asp:BoundField HeaderText="客户代码" DataField="CODE" />
                                        <asp:BoundField HeaderText="门店名称" DataField="NAME" />
                                        <asp:BoundField HeaderText="区域层次" DataField="Level" />
                                        <asp:BoundField HeaderText="经销商" DataField="Chain" Visible="false" />
                                        <asp:BoundField HeaderText="连锁门店" DataField="Banner" Visible="false" />
                                        <asp:BoundField HeaderText="客户类型" DataField="CustomerClass" />
                                        <asp:BoundField HeaderText="销售渠道" DataField="Channel" />
                                        <asp:BoundField HeaderText="地址" DataField="ADDRESS_LINE" />
                                        <asp:TemplateField HeaderText="选择">
                                            <ItemTemplate>
                                                <asp:RadioButton runat="server" ID="RadioButton1" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <RowStyle CssClass="evenline" />
                                    <AlternatingRowStyle CssClass="oddline" />
                                    <PagerSettings Visible="true" />
                                </asp:GridView>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table id="wsd_inputtable">
                        <tr>
                            <td width="100%" class="tabletitle" >
                                操作选项
                            </td>
                        </tr>
                        <tr>
                            <td class="buttonarea">
                                <asp:Button ID="btnOK" runat="server" class="wsd_button2" Text="确  定" OnClick="btnOK_Click" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr runat="server" id="trResult" visible="false">
                <td>
                    <table id="wsd_inputtable">
                        <tr>
                            <td width="100%" class="tabletitle" >
                                拜访历史 客户:<asp:Label runat="server" ID="lblCustomer"></asp:Label>
                            </td>
                        </tr>
                    </table>
                    <table id="wsd_listtable" width="100%">
                        <tr>
                            <td style="width: 100%">
                                <asp:GridView BorderWidth="0" Width="100%" ID="gvVisit" runat="server" AutoGenerateColumns="false" EmptyDataText="没有可显示的数据." 
                                EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"   
                                    EnableEmptyContentRender="true" DataKeyNames="ID" 
                                    onrowdatabound="gvVisit_RowDataBound">
                                    <HeaderStyle CssClass="titlist" />
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <a href="javascript:expandcollapse('div<%# Eval("ID") %>', 'one');">
                                                    <img id="imgdiv<%# Eval("ID") %>" alt="Click to show/hide Orders for Customer <%# Eval("ID") %>"
                                                        width="9px" border="0" src="pfeil_zu.jpg" />
                                                </a>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField HeaderText="巡店督导" DataField="NAME" />
                                        <asp:BoundField HeaderText="拜访时间" DataField="START_TIME" DataFormatString="{0:g}" />
                                        <asp:BoundField HeaderText="拜访时长(分钟)" DataField="TIME_LENGTH" />
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <tr>
                                                    <td colspan="100%">
                                                        <div id="div<%# Eval("ID") %>" style="display: none; position: relative; left: 15px;
                                                            overflow: auto; width: 97%">
                                                            <asp:GridView BorderWidth="0" Width="100%" ID="gvCPR" runat="server" AutoGenerateColumns="False" EmptyDataText="没有可显示的数据." 
                                                            EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"    OnRowDataBound="Grid_RowDataBound"
                                                                EnableEmptyContentRender="true">
                                                                <HeaderStyle CssClass="titlist" />
                                                                <Columns>
                                                                <asp:BoundField HeaderText="产品代码" DataField="CODE" />
                                                                <asp:BoundField HeaderText="产品名称" DataField="DESCRIPTION" />
                                                                    <asp:BoundField HeaderText="库存数量" DataField="INVENTORY" />
                                                                    <asp:BoundField HeaderText="是否缺货" DataField="OOS" />
                                                                    <asp:BoundField HeaderText="订单数量" DataField="QUANTITY" Visible="false"  />
                                                                    <asp:BoundField HeaderText="订单金额" DataField="AMOUNT" DataFormatString="{0:N}" Visible="false"  />
                                                                    <asp:BoundField HeaderText="是否分销" DataField="DISTRIBUTION" />
                                                                </Columns>
                                                                <RowStyle CssClass="evenline" />
                                                                <AlternatingRowStyle CssClass="oddline" />
                                                                <PagerSettings Visible="true" />
                                                            </asp:GridView>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <RowStyle CssClass="evenline" />
                                    <AlternatingRowStyle CssClass="oddline" />
                                    <PagerSettings Visible="true" />
                                </asp:GridView>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table id="wsd_inputtable">
                        <tr>
                            <td width="100%" class="tabletitle" >
                                操作选项
                            </td>
                        </tr>
                        <tr>
                            <td class="buttonarea">
                                <asp:Button ID="Button1" runat="server" class="wsd_button2" Text="重新搜索" OnClick="btnResearch_Click" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br />
    </div>
</asp:Content>
